<?php

use yii\db\Migration;

class m180409_092428_alter_orders_count extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%orders_count}}', 'teacher_id', $this->integer(11)->defaultValue(0)->comment('老师id'));
            $this->addColumn('{{%orders_count}}','teacher_name',$this->string(50)->defaultValue(0)->comment('老师姓名'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%orders_count}}', 'teacher_id');
            $this->dropColumn('{{%orders_count}}', 'teacher_name');
        }
    }
}
